package com.nxy.test.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;

/**
 * Created by snailnan on 2017/2/20.
 */
public class SocketClient {
    public static void main(String[] args) {
        try {
            Socket c = new Socket("172.17.11.217",6666);
            c.setSoTimeout(10000);
            PrintStream out = new PrintStream(c.getOutputStream());
            BufferedReader reader = new BufferedReader(new InputStreamReader(c.getInputStream()));
            String str = "hello world";
            out.println(str);

            out.println("nxy world");
            boolean flag = true;
            String sin = reader.readLine();
            System.out.println(sin);
            c.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
